package com.huatai.auth.handler;

import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @program: nanming-saas
 * @description: 授权返回信息
 * @author: songxiude
 * @create: 2024-05-29 15:10
 **/
@Data
@NoArgsConstructor
public class MyResponseResult<T>  {

	/**
	 * 响应码
	 */
	private Integer code;

	/**
	 * 响应结果消息
	 */
	private String msg;

	/**
	 * 响应数据
	 */
	private T data;

	protected MyResponseResult(Integer code, String msg, T data) {
		this.code = code;
		this.msg = msg;
		this.data = data;
	}

	public static <T> MyResponseResult<T> failed(Integer resultCode, String resultMsg) {
		return new MyResponseResult<T>(resultCode, resultMsg, null);
	}

	public static <T> MyResponseResult<T> failed(String message) {
		return new MyResponseResult<T>(ResultCode.FAILED.getCode(), message, null);
	}

	public static <T> MyResponseResult<T> failed(T data) {
		return new MyResponseResult<T>(ResultCode.SUCCESS.getCode(), ResultCode.SUCCESS.getMsg(), data);
	}

}

